#lang racket


(require (only-in "../ast/main.rkt" presentation-render-type))

(require "location.rkt")

(provide
 set-rosetta-path!
 set-rosetta-lang-path!)

(provide
 load-user-config
 
 ; render
 render-dir
 render-ext
 render-height
 cfg-render-type
 render-width
 render-size
 render-floor-width
 render-floor-height
 render-floor-size
 render-floor-color
 
 set-render-dir!
 set-render-size!
 set-render-floor-size!)


; edit: test if it is define?
; edit: only works on Windows
(define (current-user)
  (getenv "USERNAME"))

(define (user-config-path)
  (build-path (rosetta-config-path) (format "config-~A.rkt" (current-user))))

(define (load-user-config)
  (let ((path (user-config-path)))
    (when (file-exists? path)
      (dynamic-require path 0))))


; render

(define render-dir (make-parameter (find-system-path 'desk-dir)))
(define render-ext (make-parameter "png"))
(define render-height (make-parameter 300))
(define cfg-render-type (make-parameter (presentation-render-type)))
(define render-width (make-parameter 300))
(define render-floor-width (make-parameter 1000))
(define render-floor-height (make-parameter 1000))
(define render-floor-color (make-parameter 'white))

(define (render-size)
  (values (render-width) (render-height)))

(define (render-floor-size)
  (values (render-floor-width) (render-floor-height)))

(define (set-render-dir! val)
  (render-dir (path->directory-path (build-path val))))

(define (set-render-size! width height)
  (render-width width)
  (render-height height))

(define (set-render-floor-size! width height)
  (render-floor-width width)
  (render-floor-height height))